package com.situ.supermarket.controller;

import com.situ.supermarket.entity.Goods;
import com.situ.supermarket.service.GoodsService;
import com.situ.supermarket.service.impl.GoodsServiceImpl;
import com.situ.supermarket.vo.TableVO;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/goods")
public class GoodsController extends BaseController{
    GoodsService service = new GoodsServiceImpl();
    //打开页面
    public void page(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.getRequestDispatcher("/WEB-INF/goods.jsp").forward(request,response);
    }
    //查询
    public TableVO select(Integer page, Integer limit, String name, String type) {
        return service.select(page,limit,name,type);
    }
    //保存
    public void save(Goods g){
        //派上service 保存进数据库
        service.save(g);
    }
    //删除
    public void delete(Integer id){
        service.delete(id);
    }
    //修改
    public Goods info(Integer id) {
        return service.info(id);
    }
}
